package com.robot.repository;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.robot.common.enums.*;
import com.robot.dao.dto.BasicInfoDTO;
import com.robot.dao.dto.CreateRobotResultDTO;
import com.robot.dao.dto.PromptTemplateInfo;
import com.robot.dao.entity.Prologue;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Slf4j
@Data
public class RobotRepoEntity {
    // Robot表的属性
    private Long id;
    private String companyCode;
    private String robotName;
    private String robotUrl;
    private String robotDescription;
    private String characterDesign;
    private RobotScanPermissionTypeEnum robotScanPermissionType;
    private CanEditTypeEnum canEditType;
    private String categoryName;
    private Long userId;
    private Boolean isDelete;
    private Boolean isNeedWebSearching;
    private Integer robotHeat;
    private Integer robotHeatStars;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    private Long viewTimes=0L;
    private Prologue prologue;
    private PromptTemplateInfo prompt_template_info;

    // 不在robot表的属性
    // 特殊处理robotType  canEditType  prologue prompt_template_info


    public void FillFieldsByCreateRobotResultDTO(CreateRobotResultDTO createRobotResultDTO){
        this.setRobotName(createRobotResultDTO.getRobotName());
        this.setRobotDescription(createRobotResultDTO.getRobotDescription());
        this.setCharacterDesign(createRobotResultDTO.getCharacterDesign());
        createRobotResultDTO.getKnowledgeList();

        this.setPrompt_template_info(PromptTemplateInfo.builder().
                is_open_prompt_template(true).
                prompt_template(createRobotResultDTO.getPrompt_template()).
                build());

        Prologue prologue = new Prologue();
        prologue.setPrologueContent(createRobotResultDTO.getPrologue());
        prologue.setIsValid(true);
        prologue.setQuestionLead(createRobotResultDTO.getQuestionLead());
        this.setPrologue(prologue);
    }
    public RobotRepoEntity(BasicInfoDTO basicInfoDTO) {
        this.id=Long.valueOf(basicInfoDTO.getRobotId());
        this.robotName = basicInfoDTO.getRobotName();
        this.robotUrl = basicInfoDTO.getRobotUrl();
        this.robotDescription = basicInfoDTO.getRobotDescription();
        this.characterDesign = basicInfoDTO.getCharacterDesign();
        this.categoryName = basicInfoDTO.getCategoryName();
        this.robotScanPermissionType = basicInfoDTO.getRobotType();
        this.prologue = basicInfoDTO.getPrologue();
        this.prompt_template_info = basicInfoDTO.getPrompt_template_info();
    }
}
